Skip to content

test: add compressed audio socwatch test#1345

Open
ekurdybx wants to merge 2 commits intothesofproject:mainfrom
ekurdybx:compressed_audio_socwatch_test
Open

test: add compressed audio socwatch test#1345
ekurdybx wants to merge 2 commits intothesofproject:mainfrom
ekurdybx:compressed_audio_socwatch_test

Conversation

@ekurdybx
Copy link
Copy Markdown
Contributor

@ekurdybx ekurdybx commented Feb 19, 2026

Add test that plays MP3 sound and performs Socwatch analysis to check if dut enters and stays in PC10 state for the expected % of time (default expected value: 80% in PC10.2 state)
Note: this test will only pass when:

  1. the changes for playing compressed audio will be merged
  2. the currently known pc10 state issue will be resolved

@ekurdybx ekurdybx changed the title Compressed audio socwatch test NOT READY: Compressed audio socwatch test Feb 19, 2026
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch 2 times, most recently from 8a46815 to 70150f4 Compare March 5, 2026 13:42
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch 6 times, most recently from c9edb0c to f1455fb Compare March 17, 2026 12:00
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch 4 times, most recently from b3ad6c8 to a5626ac Compare March 24, 2026 14:27
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch from a5626ac to 0bcbd9a Compare April 17, 2026 10:01
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch from 0bcbd9a to 7883e5c Compare April 17, 2026 10:09
@ekurdybx ekurdybx changed the title NOT READY: Compressed audio socwatch test test: Compressed audio socwatch test Apr 17, 2026
@ekurdybx ekurdybx changed the title test: Compressed audio socwatch test test: add compressed audio socwatch test Apr 17, 2026
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch 2 times, most recently from 028929a to d2d4f57 Compare April 17, 2026 10:54
@ekurdybx ekurdybx marked this pull request as ready for review April 17, 2026 11:09
@ekurdybx ekurdybx requested review from a team, golowanow, lgirdwood and marc-hb as code owners April 17, 2026 11:09
Comment thread tools/analyze-pc-states.py Outdated
print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}")
failures += 1

return 0 if failures == 0 else 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cool but I think keeping it easier to read would be better.

Suggested change
return 0 if failures == 0 else 1
if failures == 0:
return 0
return 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch from d2d4f57 to cc6155f Compare April 17, 2026 12:02
Add test that plays mp3 audio using cplay, and check PC states with
Socwatch

Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
@ekurdybx ekurdybx force-pushed the compressed_audio_socwatch_test branch from cc6155f to 6154da5 Compare April 17, 2026 12:03
Copy link
Copy Markdown
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean and easy to read! Minor suggestions below

with open(pc_states_file, encoding="utf-8") as file:
for line in file:
m = pattern.match(line)
if m:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"early return" pattern

Suggested change
if m:
if not m:
continue

Same as you already did below but saves a lot more indentation (and mental load).

print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}")
failures += 1

if failures:
Copy link
Copy Markdown
Collaborator

@marc-hb marc-hb Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if failures:
return failures

Then you may not want the main script to exit the number of failures too because some values may have special meaning - but for sure this function has nothing better to return than the number of failures.

pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$')
failures = 0

with open(pc_states_file, encoding="utf-8") as file:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move the with open() to the caller and save even more indentation.



def analyze_pc_states(pc_states_file, expected_results):
pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regexps are notoriously cryptic. What really helps in such cases is to give a few input examples in a comment.

check_cplay_command()
{
dlogi "${play_command[@]}"
if ! "${play_command[@]}"; then
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit:

Suggested change
if ! "${play_command[@]}"; then
"${play_command[@]}" ||
die ...

expected_results="{\"PC10.2\":$pc10_threshold}"

# Analyze if the % of the time spent in given PC state was as expected
if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chmod a+x analyze-pc-states.py
I'm afraid sof-test is not going to work on Windows anytime soon!

Suggested change
if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then
if "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants